<?php
if ($_SESSION['login_user']['status'] != 'admin' || LZ_MODULE != 'admin') die('Access Denied');
if($_SESSION['login_user']['status'] != 'admin')
{
	lz_exit(ACCESS_DENIED,'admin.php',1);
}
$action = $_GET['action'];
$m = $_GET['m'];

$category_id = intval($_GET['category_id']);

include_once('model/photo_category.php');
$category = new LZ_Photo_Category;


//新建分类
if ($m == 'new_category')
{
	$data = filter_array($_POST,'name!,description');
	if ($data)
	{
		if ( $category->add( $data ) )
		{
			lz_exit(CATEGORY_NEW_SUCCESS,'admin.php?p=photo_category',1);
		}
		else
		{
			$action = 'new_category';
			$err_msg = CATEGOTY_NEW_ERROR;
		}
	}
	else
	{
		$action = 'new_category';
		$err_msg = CATEGOTY_FILL_ALL;
		$view_data['category'] = $_POST;
	}
}


//显示分类和项目列表

$categories = $category->get_list();

$view_data['categories'] = $categories;
$view_data['page_description'] = CATEGORIES_LIST;
$view_data['to_category'] = $to_category;
$view_data['real_content'] = "category_new.html";
$view_data['err_msg'] = $err_msg;
$view_data['success_msg'] = $success_msg;
$view_data['category_id'] = $category_id;
?>